<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 鼠标移入鼠标移出 -->
    <div class="box">
        鼠标移入改变样式，鼠标移出恢复
    </div>
</body>
<script>

    var box = document.querySelector(".box")
    box.onmouseover = function () {
        box.style.background = "#ddd"
        box.style.color = "red"
        box.style.borderColor = "red"
    } 
    box.onmouseout = function () {
        box.style.background = "black"
        box.style.color = "white"
        box.style.borderColor = "black"
    }

</script>

</html>
<style>
    .box {
        width: 200px;
        height: 200px;
        background-color: black;
        color: white;
        border: 10px solid black;
        margin: 0 auto;

    }
</style>